<?php
namespace App\Repositories\GameServer;

use App\Models\GameServer\Gift;

class GiftRepository
{
    //获取所有商品
    public function getGifts()
    {
        return Gift::orderBy('enable', 'desc')->orderBy('order_id', 'desc')->orderBy('id', 'desc')->get();
    }

    public function getGift($id)
    {
        return Gift::find($id);
    }

    public function addGift($request)
    {
        $params = $request->all();

        return Gift::create($params);
    }

    public function updateGift($request, $id)
    {
        return Gift::find($id)->update($request->all());
    }

    public function deleteGift($id)
    {
        return Gift::destroy($id);
    }

    public function destroyList($ids)
    {
        return Gift::destroy($ids);
    }

    public function editStatus($id, $status)
    {
        $gift = Gift::findOrFail($id);
        $gift->enable = $status;

        $gift->save();

        return true;
    }
}